<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Promise对象</title>
</head>
<body>

</body>
<script type="text/javascript">

    async function test() {
        var flag = await new Promise(function (reslove,reject) {
            setTimeout(function (flag) {
                if(flag){
                    console.log("success-1")
                    reslove(flag);
                }else{
                    console.log("error-1");
                    reject("报错了-1");
                    return;
                }
            },1000,true)
        });
        var flag2 = await new Promise(function (reslove,reject) {
            setTimeout(function (flag) {
                if(flag){
                    console.log("success-2");
                    reslove(flag);
                }else{
                    console.log("error-2");
                    reject();
                    return;
                }
            },1000,flag)
        });
        await new Promise(function (reslove,reject) {
            setTimeout(function (flag) {
                if(flag){
                    console.log("success-3");
                    reslove();
                }else{
                    console.log("error-3");
                    reject("报错-3");
                    return;
                }
            },1000,!flag2)
        })
    };

    test();

</script>

</html>